# -*- coding:utf8 -*-

import os.path
from AcideAmine import AcideAmine
import pickle
import os

def initListeAcideAmine():
    """function initListeAcideAmine

    returns
    """
    if(os.path.exists('aa.list')):
        return pickle.load(open('aa.list', 'r'))
    else:
        listeAcideAmine = {}
        
        #Definition of AcideAmine
        phenylalanine = AcideAmine('phenylalaline')
        phenylalanine.addCodon('UUU')
        phenylalanine.addCodon('UUC')
        phenylalanine.setCondonDefault('UUU')
        listeAcideAmine[len(listeAcideAmine)] = phenylalanine

        leucine = AcideAmine('leucine')
        leucine.addCodon('UUA')
        leucine.addCodon('UUG')
        leucine.addCodon('CUU')
        leucine.addCodon('CUC')
        leucine.addCodon('CUA')
        leucine.addCodon('CUG')
        leucine.setCondonDefault('UUA')
        listeAcideAmine[len(listeAcideAmine)] = leucine

        isoleucine = AcideAmine('isoleucine')
        isoleucine.addCodon('AUU')
        isoleucine.addCodon('AUC')
        isoleucine.addCodon('AUA')
        isoleucine.setCondonDefault('AUU')
        listeAcideAmine[len(listeAcideAmine)] = isoleucine

        valine = AcideAmine('valine')
        valine.addCodon('GUU')
        valine.addCodon('GUC')
        valine.addCodon('GUA')
        valine.addCodon('GUG')
        valine.setCondonDefault('GUU')
        listeAcideAmine[len(listeAcideAmine)] = valine

        serine = AcideAmine('serine')
        serine.addCodon('UCU')
        serine.addCodon('UCC')
        serine.addCodon('UCA')
        serine.addCodon('UCG')
        serine.setCondonDefault('UCU')
        listeAcideAmine[len(listeAcideAmine)] = serine

        proline = AcideAmine('proline')
        proline.addCodon('CCU')
        proline.addCodon('CCC')
        proline.addCodon('CCA')
        proline.addCodon('CCG')
        proline.setCondonDefault('CCU')
        listeAcideAmine[len(listeAcideAmine)] = proline

        threonine = AcideAmine('threonine')
        threonine.addCodon('ACU')
        threonine.addCodon('ACC')
        threonine.addCodon('ACA')
        threonine.addCodon('ACG')
        threonine.setCondonDefault('ACU')
        listeAcideAmine[len(listeAcideAmine)] = threonine

        alanine = AcideAmine('alanine')
        alanine.addCodon('GCU')
        alanine.addCodon('GCC')
        alanine.addCodon('GCA')
        alanine.addCodon('GCG')
        alanine.setCondonDefault('GCU')
        listeAcideAmine[len(listeAcideAmine)] = alanine

        tyrosine = AcideAmine('tyrosine')
        tyrosine.addCodon('UAU')
        tyrosine.addCodon('UAC')
        tyrosine.setCondonDefault('UAU')
        listeAcideAmine[len(listeAcideAmine)] = tyrosine

        histidine = AcideAmine('histidine')
        histidine.addCodon('CAU')
        histidine.addCodon('CAC')
        histidine.setCondonDefault('CAU')
        listeAcideAmine[len(listeAcideAmine)] = histidine

        glutamine = AcideAmine('glutamine')
        glutamine.addCodon('CAA')
        glutamine.addCodon('CAG')
        glutamine.setCondonDefault('CAA')
        listeAcideAmine[len(listeAcideAmine)] = glutamine

        asparagine = AcideAmine('asparagine')
        asparagine.addCodon('AAU')
        asparagine.addCodon('AAC')
        asparagine.setCondonDefault('AAU')
        listeAcideAmine[len(listeAcideAmine)] = asparagine

        lysine = AcideAmine('lysine')
        lysine.addCodon('AAA')
        lysine.addCodon('AAG')
        lysine.setCondonDefault('AAA')
        listeAcideAmine[len(listeAcideAmine)] = lysine

        acideAspartique = AcideAmine('Acide Aspartique')
        acideAspartique.addCodon('GAU')
        acideAspartique.addCodon('GAC')
        acideAspartique.setCondonDefault('GAU')
        listeAcideAmine[len(listeAcideAmine)] = acideAspartique

        acideGlutamique = AcideAmine('Acide Gultamique')
        acideGlutamique.addCodon('GAA')
        acideGlutamique.addCodon('GAG')
        acideGlutamique.setCondonDefault('GAA')
        listeAcideAmine[len(listeAcideAmine)] = acideGlutamique

        cysteine = AcideAmine('cysteine')
        cysteine.addCodon('UGU')
        cysteine.addCodon('UGC')
        cysteine.setCondonDefault('UGU')
        listeAcideAmine[len(listeAcideAmine)] = cysteine

        tryptophane = AcideAmine('tryptophane')
        tryptophane.addCodon('UGG')
        tryptophane.setCondonDefault('UGG')
        listeAcideAmine[len(listeAcideAmine)] = tryptophane

        arginine = AcideAmine('argigine')
        arginine.addCodon('CGU')
        arginine.addCodon('CGC')
        arginine.addCodon('CGA')
        arginine.addCodon('CGG')
        arginine.addCodon('AGA')
        arginine.addCodon('AGG')
        arginine.setCondonDefault('CGU')
        listeAcideAmine[len(listeAcideAmine)] = arginine

        serine = AcideAmine('serine')
        serine.addCodon('AGU')
        serine.addCodon('AGC')
        serine.setCondonDefault('AGU')
        listeAcideAmine[len(listeAcideAmine)] = serine

        glycine = AcideAmine('glycine')
        glycine.addCodon('GGU')
        glycine.addCodon('GGC')
        glycine.addCodon('GGA')
        glycine.addCodon('GGG')
        glycine.setCondonDefault('GGU')
        listeAcideAmine[len(listeAcideAmine)] = glycine

        #pickle.dump(listeAcideAmine,open('aa.list','w+'))
        return listeAcideAmine
